package com.momchil_and_marin.javanet.bll;

import java.io.IOException;

/**
 * This interface provides methods for managing
 * user data and information.
 */
public interface UserService {
	
	/**
	 * This method just checks if the specified username is
	 * valid and can be handled by the backend.
	 * @param username the username to be validated.
	 * @return <code>true</code> if the username is valid,
	 * <code>false</code> otherwise.
	 */
	public boolean isValidUsername(String username);
	
	/**
	 * This method just checks if the specified password is
	 * valid and can be handled by the backend.
	 * @param password the password to be validated.
	 * @return <code>true</code> if the password is valid,
	 * <code>false</code> otherwise.
	 */
	public boolean isValidPassword(String password);
	
	/**
	 * Checks if the specified <code>email</code> has a
	 * valid syntax.
	 * @param email e-mail to be validated.
	 * @return <code>true</code> if the e-mail is valid,
	 * <code>false</code> otherwise.
	 */
	public boolean isValidEmail(String email);
	
	/**
	 * Checks if the specified <code>firstName</code> is
	 * valid (e.g. does not contain white spaces).
	 * @param firstName first name ot be validated.
	 * @return <code>true</code> if the name is valid,
	 * <code>false</code> otherwise.
	 */
	public boolean isValidFirstName(String firstName);
	
	/**
	 * Checks if the specified <code>lastName</code> is
	 * valid (e.g. does not contain white spaces).
	 * @param lastName last name to be validated.
	 * @return <code>true</code> if the name is valid,
	 * <code>false</code> otherwise.
	 */
	public boolean isValidLastName(String lastName);
	
	/**
	 * Returns whether a user with the specified <code>username</code>
	 * and <code>password</code> exists.
	 * @param username username of the user
	 * @param password password of the user
	 * @return <code>true</code> if such a user is registered, 
	 * <code>false</code> otherwise.
	 * @throws IOException if an I/O error occurs.
	 * @throws UserServiceException due to a data processing error.
	 */
	public boolean isUserAvailable(String username, String password) 
			throws UserServiceException, IOException;

	/**
	 * Returns information on the user with the specified
	 * <code>username</code> or <code>null</code> of such a
	 * user does not exist.
	 * @param username username of the user
	 * @return an instance of {@link User} if such a user exists,
	 * otherwise <code>null</code>.
	 * @throws IOException if an I/O error occurs.
	 * @throws UserServiceException due to a data processing error.
	 */
	public User getUser(String username) throws UserServiceException, IOException;

}
